import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class T9Spelling {
	private static String k[] = {"2","22","222","3","33","333","4","44","444","5","55","555","6","66","666","7","77","777","7777","8","88","888","9","99","999","9999"};
	public static void main(String[] args) throws IOException {
		BufferedReader rdr = new BufferedReader(new InputStreamReader(System.in));
		try {
			int N = Integer.parseInt(rdr.readLine());
			for(int n = 1; n <= N; n++) {
				char[] c = rdr.readLine().toCharArray();
				char pc = 'A';
				System.out.print("Case #" + n + ": ");
				for(char ch : c) {
					String p = ch == ' ' ? "0" : k[ch - 'a'];
					if(pc == p.charAt(0))
						System.out.print(" ");
					System.out.print(p);
					pc = p.charAt(p.length() - 1);
				}
				System.out.println();
			}
		} finally {
			rdr.close();
		}
	}
}
